package com.wxb.shmily.service;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.wxb.shmily.bean.user.User;
import com.wxb.shmily.dao.UserMapper;
import com.wxb.shmily.user.api.UserService;
import com.wxb.shmily.util.DigestUitl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by shmily on 2018/6/6.
 */
@Service("userService")
public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements UserService {
    @Resource
    private UserMapper userDao;

    @Override
    public User user() {
        return userDao.user();
    }

    @Override
    public User login(String nickName, String password) {
        try {
            String pass = DigestUitl.PASSWORD(password);
            Map<String, Object> map = new HashMap<>();
            map.put("nickName", nickName);
            map.put("password", pass);
            return userDao.login(map);
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
}
